import { http } from '@/utils/http'

export interface SearchListParams {
  Keyword?: string
  Type?: number[]
  startTime?: string
  endTime?: string
  paStatus?: number
  types?: string
  page?: number
  limit?: number
  key?: string
}

export interface SearchItem {
  resId: number
  resName: string
  resType: number
  cateId: number
  cateName: string
  tags: string
  resImg: string
  resTime: string
  likeNum: number
  lookNum: number
  commentNum: number
  overTime: string
  openCrowd: string
  openCrowdOption: string
  cateImg: string
  isLike: number
  isCollect: number
  content: string
  cateContent: string
  webUrl: string
  isLook: number
  isCompele: number
  cpbProductIntroduction: string
  allowTimes: number
  testTimes: number
  timeLength: number
  optionKey: number
  products: any
  resCover: string
  cateCover: string
  startTime: string | null
  endTime: string | null
  cateNameEn: string
}

export interface SearchData {
  totalCount: number
  items: SearchItem[]
}

export const searchList = ({
  Keyword,
  Type, // 0 课程 11知识
  startTime,
  endTime,
  paStatus,
  types,
  page = 1,
  limit = 10,
}: SearchListParams = {}): Promise<IResData<SearchData>> => {
  return http.get<SearchData>('/api/MP/GetSearchList', {
    Keyword,
    Type,
    startTime,
    endTime,
    paStatus,
    types,
    page,
    limit,
  })
}
